<template>
  <el-dialog title="提示" :visible.sync="dialogVisible" width="30%" :before-close="handleClose">
    <el-input v-model="inputValue"></el-input>
    <span slot="footer" class="dialog-footer">
      <el-button @click="dialogVisible = false">取 消</el-button>
      <el-button type="primary" @click="comfirm">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  props: {
    visible: {
      type: Boolean,
      require: true
    }
  },
  data () {
    return {
      dialogVisible: false,
      inputValue: "",
    }
  },
  methods: {
    handleClose () {

    },
    comfirm () {
      this.dialogVisible = false;
      this.$emit("comfirm", this.inputValue)
    }
  },
  watch: {
    visible (newVal) {
      this.dialogVisible = newVal;
    },
    dialogVisible (newVal, oldVal) {
      if (newVal) {
        this.inputValue = "";
      } else {
        this.$emit("update:visible", false)
      }
    }
  }
}
</script>

<style>
</style>